//
//  MyCommentOfIslanCell.m
//  diaoyuren
//
//  Created by 钓鱼人 on 16/4/15.
//  Copyright © 2016年 game. All rights reserved.
//

#import "MyCommentOfIslanCell.h"
#import "TQStarRatingView.h"
#import "LoginController.h"
#import "UILabel+BoundRect.h"
@interface MyCommentOfIslanCell ()
@property (weak, nonatomic) IBOutlet MBLabelWithFontAdapter *nameLab;
@property (weak, nonatomic) IBOutlet UIView *starView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *starWidth;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *starHight;

@property (weak, nonatomic) IBOutlet MBLabelWithFontAdapter *timeLab;
@property (weak, nonatomic) IBOutlet MBLabelWithFontAdapter *commentLab;

@property (weak, nonatomic) IBOutlet UIImageView *comBakImg;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *backImageHeight;


@property (nonatomic,strong) TQStarRatingView *starRating;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *linHeight;

@end

@implementation MyCommentOfIslanCell

- (void)awakeFromNib {
    self.selectionStyle = 0;
 
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    self.starHight.constant = SCREEN_HEIGHT*0.03;
    CGFloat hh = self.starHight.constant;
    self.starWidth.constant = (hh*(1.05))*5+(hh/1.5);

    self.comBakImg.image = [[UIImage imageNamed:@"bg_word"]stretchableImageWithLeftCapWidth:0 topCapHeight:10];
    
    self.linHeight.constant = 0.5;
}

-(void)setModel:(MycommetListModel *)model{
    _model = model;
    
    self.nameLab.text = _model.name;
    self.timeLab.text = _model.addtime;
    _commentLab.text = _model.comment;

    CGRect sizerect = [_commentLab boundingRectWithInitSize:CGSizeMake(SCREEN_WIDTH-60, 0)];

    self.cellHight = sizerect.size.height+SCREEN_HEIGHT*0.17;

}

-(void)drawRect:(CGRect)rect{
    [super drawRect:rect];

    self.starRating = [[TQStarRatingView alloc]initWithFrame:CGRectMake(0, 0, W(self.starView), H(self.starView))];

   [self.starView addSubview:self.starRating];

    [self.starRating StarForegroundViewWithScore:_model.score];
    
    CGRect sizerect = [_commentLab boundingRectWithInitSize:CGSizeMake(_commentLab.width, 0)];
    
    _comBakImg.height = sizerect.size.height;
    
    self.backImageHeight.constant = sizerect.size.height+18;
    [self.contentView bringSubviewToFront:_commentLab];
}


@end
